﻿// -----------------------------------------------------------------------
// <copyright file="Team.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace BCS.Business
{
        using System;
        using System.Linq;
        using BCS.Model;
        using BCS.Common;

        /// <summary>
        /// TODO: Update summary.
        /// </summary>
        public class Team 
        {
                public Team(TeamModel model)
                {
                        Model = model;
                }

                public String Name
                {
                        get
                        {
                                return Model.Name;
                        }
                }

                public DateTime StartTime
                {
                        get
                        {
                                return Model.StartTime;
                        }
                }

                public DateTime EndTime
                {
                        get
                        {
                                return Model.EndTime;
                        }
                        set
                        {
                                if (value != Model.EndTime)
                                {
                                        Model.EndTime = value;
                                }
                        }
                }

                public TeamModel Model { get; private set; }

                public Int32 Count
                {
                        get
                        {
                                return (from i in BusinessCache.Instance.Records
                                        where i.CreateTime > StartTime && i.CreateTime < EndTime
                                        select i).Sum(i => i.Count);
                        }
                }
        }
}